package edu.colorado.epmapp.form;

import java.util.Hashtable;

import org.json.JSONObject;

import edu.colorado.epmapp.models.EPMDefs.PetGender;
import edu.colorado.epmapp.models.EPMDefs.PetSize;
import edu.colorado.epmapp.models.EPMDefs.PetStatus;
import edu.colorado.epmapp.models.EPMDefs.PetType;
import edu.colorado.epmapp.network.OnResponseListener;
import edu.colorado.epmapp.network.ReportNetwork;


public class PetForm extends BaseForm {
	ReportNetwork network = new ReportNetwork(null);
	Hashtable<String, Object> formFields = new Hashtable<String, Object>();
	
	public PetForm() {
	}

	public void setPetType(PetType type){
		
		formFields.put("pet_type", 	type.toString());
	}
	
	public void setPetStatus(PetStatus status){
		formFields.put("status", status.toString());
	}
	
	public void setPetGender(PetGender gender){
		formFields.put("sex", gender.toString());
	}
	
	public void setPetSize(PetSize size){
		formFields.put("size", size.toString());
	}
	
	public void setPetName(String name){
		formFields.put("pet_name", name);
	}
	
	public void setLocation(String location){
		formFields.put("location", location);
	}
	
	public void setDate(String date){
		formFields.put("date_lost_or_found", date);
	}
	
	public void setPetColor(String color){
		formFields.put("color", color);
	}
	
	public void setPetBreed(String breed){
		formFields.put("breed", breed);
	}
	
	public void setPetAge(String age){
		formFields.put("age", age);
	}
	
	public void setPetDescription(String description){
		formFields.put("description", description);
	}
	
	public void setProposedBy(String proposedBy)
	{
		formFields.put("proposed_by", proposedBy);
	}
	
	public void setImagePath(String image)
	{
		formFields.put("img_path", image);
	}
	
	public void setGeoLocLat(String geoLat)
	{
		formFields.put("geo_location_lat", geoLat);
	}
	
	public void setGeoLocLong(String geoLong)
	{
		formFields.put("geo_location_long", geoLong);
	}
	
	public void setMicrochipId(String id)
	{
		formFields.put("microchip_id", id);
	}
	
	public void setTagInfo(String tag)
	{
		formFields.put("tag_info", tag);
	}
	
	public void setContactName(String name)
	{
		formFields.put("contact_name", name);
	}
	
	public void setContactNumber(String number)
	{
		formFields.put("contact_number", number);
	}
	
	public void setSpayedOrNeutered(String spn)
	{
		formFields.put("spayed_or_neutered", spn);
	}
	
	/*public void setWorker(String workers)
	{
		formFields.put("workers", workers);
	}
	
	public void setBookmarkedBy(String bookmarkedBy)
	{
		formFields.put("bookmarked_by",bookmarkedBy);
	}*/
	
	@Override
	public void submitForm(OnResponseListener listener){
		JSONObject jsObject = new JSONObject();
		try{
			for(String key : formFields.keySet()){
				jsObject.put(key, formFields.get(key));
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		String jsonString = jsObject.toString();
		//DEBUG
		System.out.println(jsonString);
		network.submitReport(jsonString, listener);
	}
	
}
